//  定义首页的左侧菜单对应的二级路由规则
import React, { Component, lazy, Suspense } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import Loading from '@/components/Loading'
// 引入lazy 对应的组件 
const Welcome = lazy(() => import('@/views/dashboard/Welcome'))
const UserList = lazy(() => import('@/views/dashboard/user/Index'))
const FilmList = lazy(() => import('@/views/dashboard/film/Index'))
const CinemaList = lazy(() => import('@/views/dashboard/cinema/Index'))
//  显示组件之前有一个loading效果
class Admin extends Component {
    render() {
        return (
            <Suspense fallback={<Loading></Loading>}>
                <Switch>
                    <Route path='/dashboard/welcome' component={Welcome}></Route>
                    <Route path='/dashboard/user/index' component={UserList}></Route>
                    <Route path='/dashboard/film/index' component={FilmList}></Route>
                    <Route path='/dashboard/cinema/index' component={CinemaList}></Route>
                    <Redirect from='/dashboard' to='/dashboard/welcome' exact></Redirect>
                </Switch>
            </Suspense>
        );
    }
}

export default Admin;
